package org.hikari.qqbot.xiuxian.command;

import java.util.Date;

/**
 * created at 2024-12-18 01:32:12
 *
 * @author yinchao
 * @version 1.0
 **/
public abstract class AbstractLogicalCommand implements ICommand {

    protected final ICommand command;

    public AbstractLogicalCommand(ICommand command) {
        this.command = command;
    }

    @Override
    public String getCommand() {
        return command.getCommand();
    }

    @Override
    public String toString() {
        return getCommand();
    }

    @Override
    public Long getUserId() {
        return command.getUserId();
    }

    @Override
    public Long getGroupId() {
        return command.getGroupId();
    }

    @Override
    public ICommand groupId(Long groupId) {
        command.groupId(groupId);
        return this;
    }

    @Override
    public ICommand userId(Long userId) {
        command.userId(userId);
        return this;
    }

    @Override
    public ICommand delay(Date date) {
        command.delay(date);
        return this;
    }

    @Override
    public Date getSendTime() {
        return command.getSendTime();
    }

    public ICommand delegate(boolean basic) {
        if (basic) {
            return command instanceof AbstractLogicalCommand c ? c.delegate(true) : command;
        }
        return command;
    }

}
